package com.zzb.framework.frameworkcontroller;

import com.alibaba.fastjson.JSON;
import com.zzb.framework.common.BaseResponse;
import com.zzb.framework.common.ServiceException;
import com.zzb.framework.frameworkcontroller.common.FrameworkBaseController;
import com.zzb.framework.log.service.SysLogService;
import com.zzb.framework.user.entity.User;
import com.zzb.framework.user.form.UserLoginForm;
import com.zzb.framework.user.service.LoginHistoryService;
import com.zzb.framework.user.service.UserService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 框架后台管理
 * Created by zhangzhenbin on 17-5-2.
 */
@RequestMapping("/framework")
@Controller
@Api(value = "框架后台管理",tags = "框架后台管理")
public class FrameworkController extends FrameworkBaseController {
    private static final Logger logger = LoggerFactory.getLogger(LoginHistoryService.class);
    @Autowired
    private UserService userService;
    @Autowired
    private SysLogService sysLogService;

    @RequestMapping({"","/","/index"})
    public String index(HttpServletRequest request, Model model){
        logger.debug("in framework index page");
        return "framework/index";
    }

    @ResponseBody
    @RequestMapping("test")
    public BaseResponse test(){
        try {
            sysLogService.testTransaction();
        } catch (ServiceException e) {
            return new BaseResponse(BaseResponse.FAIL,e.getMessage());
        }
        return new BaseResponse(BaseResponse.SUCCESS,"");
    }

}
